#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#define ONE_K (1024)

int main()
{
	char* some_menory;
	int size_to_allocate = ONE_K;
	int megs_obtained = 0;
	int ks_obtained = 0;

	while(1){
		for(ks_obtained = 0; ks_obtained<1024; ks_obtained++)
		{
			some_menory = (char*)malloc(size_to_allocate);
			if(some_menory ==NULL) exit(EXIT_FAILURE);
			sprintf(some_menory, "Hello world");
		}
		megs_obtained++;
		printf("Now allocated %d MegaBytes\n",megs_obtained);
	}
	exit(EXIT_SUCCESS);
}
